package com.坦克大战.Tank_6;

import javax.swing.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Scanner;

@SuppressWarnings("all")
public class TankGameMain extends JFrame {
    public static void main(String[] args) {
        TankGameMain tankGameMain = new TankGameMain();
    }

    MyPanel panel = null;

    public TankGameMain() {
        System.out.println("1：选择新游戏  2：选择上局游戏");
        String key = new Scanner(System.in).next();
        this.panel = new MyPanel(key);  ///创建画板
        new Thread(panel).start();   ///启动刷新画板的线程
        this.add(panel);             ///将画板添加到该界面
        this.setSize(1500, 740);   ///画布大小
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  ///点击 × 就退出
        this.setVisible(true);     ///是否显示
        this.addKeyListener(panel);   ///添加键盘监听到画板
        this.addWindowListener(new WindowAdapter() {  /// 监听关闭按钮，重写正在关闭过程的按钮；
            @Override
            public void windowClosing(WindowEvent e) {
                Recorder.RecordTankGameScores();    ///如果监听到关闭中，就调用Recorder的记录方法，把击毁数量存到文件中
            }
        });


    }

}
